<template>
	<view class="container">
		<news-item :newsData='newsList' @sendIdEvent="getId"></news-item>
	</view>
</template>

<script>
	import newsItem from '../../components/newsList/newsItem.vue'
	export default {
		data() {
			return {
				newsList:[]
			}
		},
		components:{
			"news-item":newsItem
		},
		methods: {
			async getNewsList(){
				const res = await this.$http({url:"/api/getnewslist"})
				this.newsList = res.data.message
			},
			getId(id){
				uni.navigateTo({
					url:'../detail/detail?id='+id
				})
			}
		},
		onLoad(){
			this.getNewsList()
		}
	}
</script>

